package com.ruoyi.buss.customer.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.buss.customer.domain.DataWgYsh;
import com.ruoyi.buss.customer.service.IDataWgYshService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 预授信信息Controller
 * 
 * @author ruoyi
 * @date 2021-07-16
 */
@RestController
@RequestMapping("/ysh")
public class DataWgYshController extends BaseController
{
    @Autowired
    private IDataWgYshService dataWgYshService;

    /**
     * 查询预授信信息列表
     */
    @PreAuthorize(hasPermi = "buss:ysh:list")
    @GetMapping("/list")
    public TableDataInfo list(DataWgYsh dataWgYsh)
    {
        startPage();
        List<DataWgYsh> list = dataWgYshService.selectDataWgYshList(dataWgYsh);
        return getDataTable(list);
    }

    /**
     * 导出预授信信息列表
     */
    @PreAuthorize(hasPermi = "buss:ysh:export")
    @Log(title = "预授信信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataWgYsh dataWgYsh) throws IOException
    {
        List<DataWgYsh> list = dataWgYshService.selectDataWgYshList(dataWgYsh);
        ExcelUtil<DataWgYsh> util = new ExcelUtil<DataWgYsh>(DataWgYsh.class);
        util.exportExcel(response, list, "预授信信息数据");
    }

    /**
     * 获取预授信信息详细信息
     */
    @PreAuthorize(hasPermi = "buss:ysh:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(dataWgYshService.selectDataWgYshById(id));
    }

    /**
     * 新增预授信信息
     */
    @PreAuthorize(hasPermi = "buss:ysh:add")
    @Log(title = "预授信信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataWgYsh dataWgYsh)
    {
        return toAjax(dataWgYshService.insertDataWgYsh(dataWgYsh));
    }

    /**
     * 修改预授信信息
     */
    @PreAuthorize(hasPermi = "buss:ysh:edit")
    @Log(title = "预授信信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataWgYsh dataWgYsh)
    {
        return toAjax(dataWgYshService.updateDataWgYsh(dataWgYsh));
    }

    /**
     * 删除预授信信息
     */
    @PreAuthorize(hasPermi = "buss:ysh:remove")
    @Log(title = "预授信信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(dataWgYshService.deleteDataWgYshByIds(ids));
    }
}
